#!/usr/bin/perl -w # For syntax highlighting
package clreqd_modules;

use strict;
use Data::Dumper;
use vm_info;

sub vm_migratetransport_check {
my %ARGS=@_;

	my $type=$ARGS{TYPE};
	my $transport=$ARGS{TRANSPORT};
	my $vm=new vm_info($type);
	if(!defined($vm)) {
		return "FAIL " . vm_info::error();
	}
	my ($a,$b,$c)=$vm->validate_transport($transport);
	if($a==1) {
		return "WARN VM type of '$type' does not support transport settings.";
	}
	if($a==0) {
		if( (!defined($b) || @$b==0) && 
		    (!defined($c) || @$c==0)) {
			return "OK";
		}
		my $errors=0;
		my @E=();
		if(defined($b)) {
			$errors=1;
			push @E,"ERROR $_" foreach(@$b);
		}
		if(defined($c)) {
			push @E,"WARN $_" foreach(@$c);
		}
		return "OK" if @E==0;
		if($errors) {
			return "ERROR\n" . join("\n",@E);
		}
		return "WARN\n" . join("\n",@E);
	}
	return "ERROR $b";
}

1;
